<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "t_sign_up".
 *
 * @property int $id ID
 * @property int $activityId 活动ID
 * @property int $sessionId 场次ID
 * @property int $type 类型(1:个人,2:团体)
 * @property string $teamName 活动名
 * @property int $persons 人数
 * @property string $progName 节目名称
 * @property string $realName 真实姓名
 * @property string $idcard 身份证
 * @property string $phone 电话
 * @property int $sex 性别(1:男，2：女)
 * @property string $recommandComp 推荐单位
 * @property string $address 家庭地址
 * @property string $emgContact 紧急联系人
 * @property string $emgPhone 紧急电话
 * @property int $_intm 创建时间
 * @property int $status 报名状态(0:取消, 1:报名中,2:支付成功，3:正常结束)
 */
class TSignUp extends \yii\db\ActiveRecord
{
    const TYPE_PERSON = 1;
    const TYPE_TEAM = 2;

    const STATUS_INIT = 1;
    const STATUS_PAYED = 2;
    const STATUS_FINISH = 3;
    const STATUS_CANEL = 0;
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 't_sign_up';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['activityId', 'sessionId', 'type', 'persons', 'sex', '_intm', 'status', 'teamIdype'], 'integer'],
            [['type', 'progName', 'phone', 'realName'], 'required'],
            [['teamName', 'progName', 'recommandComp', 'address', 'emgContact'], 'string', 'max' => 255],
            [['realName', 'idcard', 'phone', 'emgPhone'], 'string', 'max' => 20],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'activityId' => '活动ID',
            'sessionId' => '场次ID',
            'type' => '类型(1:个人,2:团体)',
            'teamName' => '活动名',
            'persons' => '人数',
            'progName' => '节目名称',
            'realName' => '真实姓名',
            'idcard' => '身份证',
            'phone' => '电话',
            'sex' => '性别(1:男，2：女)',
            'recommandComp' => '推荐单位',
            'address' => '家庭地址',
            'emgContact' => '紧急联系人',
            'emgPhone' => '紧急电话',
            '_intm' => '创建时间',
            'status' => '报名状态(0:取消, 1:报名,2:正常结束)',
        ];
    }

    public function getActivity(){
        return $this->hasOne(TActivity::class, ['id' => 'activityId']);
    }

    public function getSession(){
        return $this->hasOne(TSession::class, ['id' => 'sessionId']);
    }
}
